﻿@{
    Layout = null;
}
<!DOCTYPE html> 
<html>
    <head>
        <title>团队登录</title>
        <meta charset="utf-8">
        <meta name="keywords" content="裸钻、统包货、戒托、成品" /> 
        <meta name="description" content="白钻、彩钻批发与零售，统包货批发与零售，戒托、成品批发与零售" />  
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta content="yes" name="apple-mobile-web-app-capable">
        <meta content="black" name="apple-mobile-web-app-status-bar-style">
        <meta content="telephone=no" name="format-detection">
        <link rel="stylesheet" href="~/css/common.css" />
       <link rel="apple-touch-icon" href="touch-icon-iphone.png" />
    </head>
    <body>
        <section>
            <header>
                <a class="back-btn"  href="/Customer/Index"></a>
                <h2>团队登录</h2>
            </header>
         <article>
             <ul id="login-data" class="layout-box login-box">
                 <li>
                     <em class="user-icon"></em>
                     <input type="text" class="input-box login-name" placeholder="请输入登录名" required="required" autofocus="autofocus"/>
                 </li>
                  <li>
                     <em class="pwd-icon"></em>
                     <input type="password" class="input-box login-pwd" placeholder="请输入密码" required="required" />
                 </li>
                
             </ul>
              <a class="sure-btn login-btn">登录</a>
             <div class="tip-box login-tip-box">
                 <div class="tip login-tip">
                     <p class="msg login-msg"></p>
                     <span class="colse-tip-btn">确定</span>
                 </div>
             </div>
         </article>
        </section>
    </body>
</html>
 <script src="~/js/jquery.min.js"></script>
        <script>
            (function () {
                var team = {
                    init: function () {
                        this.bindEvents();
                    },
                    bindEvents: function () {
                        var self = this;
                        //点击登录
                        $(".login-btn").on("click", function () {
                            self.validateLogin();
                        });
                        //关闭登录错误提示按钮
                        $(".colse-tip-btn").on("click",function () {
                            $(".login-tip-box").hide();//隐藏提示盒子
                            $(".login-box .login-pwd").val("");//密码清空
                        });
                    },
                    //验证登录
                    validateLogin: function () {
                        var self = this;
                        var name = $(".login-name").val();//获取填写的用户名
                        var pwd = $(".login-pwd").val();//获取填写的密码
                        if (name && pwd) {//用户名和密码都不为空
                            self.teamLogin();//调用登录方法
                        } else {//否则
                            $(".login-tip-box").show();//显示提示框
                            if (name) {//name不为空
                                $(".login-msg").html("请输入密码");//显示输入密码
                            }
                            else if (pwd) {//pwd不为空
                                $(".login-msg").html("请输入账号");//显示输入账号
                            } else {
                                $(".login-msg").html("请输入账号与密码");//显示账号与密码
                            }
                        }
                    },
                    //团队登录
                    teamLogin: function () {
                        $.ajax({
                            url: "/Team/UserLogin",//提交地址
                            type: "POST",//提交方式
                            data: "{'Name':'" + $(".login-name").val() + "','Pwd':'" + $(".login-pwd").val() + "'}",
                            contentType: "application/json; charset=utf-8",
                            success: function (result) {

                                var _result = eval('(' + result + ')');//eval()解析单个json对象

                                if (_result['msgcode'] == false) {//返回错误
                                    $(".login-tip-box").show();//显示提示盒子
                                    $(".login-msg").html(_result['msginfo']);//盒子内容文字

                                } else {//返回true
                                    window.location.href = "/team/Order";//跳到团队订单页面
                                }
                            }
                        });
                    },
                };
                team.init();
            })();
        </script>